package cn.tedu.egmybatis1.mapper;

import cn.tedu.egmybatis1.pojo.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("insert into product(title,price,stock) " +
            "values (#{title},#{price},#{stock})")
    int insertProduct(Product product);
    @Select("select id,title,price,stock " +
            "from product " +
            "where id = #{id}")
    Product selectById(Integer id);
    @Delete("delete from product " +
            "where id = #{id}")
    int deleteById(Integer id);
    @Select("select * from product ")
    List<Product> selectAll();

}
